/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.archive.controller;

import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.ucase.archive.dto.*;
import com.icinfo.cloud.provider.punish.ucase.archive.service.ICaseElectricArchiveRecordService;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 描述:  case_electric_archive_record 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年12月08日
 */
@RestController
@RequestMapping("/punish/ucase/archive")
@Slf4j
public class CaseElectricArchiveRecordController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseElectricArchiveRecordController.class);

    @Autowired
    private ICaseElectricArchiveRecordService caseElectricArchiveRecordService;

    /**
     * 【V1.9.4】描述：查询电子卷宗列表-办案人使用
     *
     * @param queryDto 查询dto
     * @return {@link Result<PageResponse<CaseElectricArchiveRecordDetailVo>> }
     * @author shishengyao
     * @date 2022/12/08
     */
    @RequestMapping("/getElectricArchiveRecordList")
    public Result<PageResponse<CaseElectricArchiveRecordDetailVo>> getElectricArchiveRecordList(@RequestBody @Validated CaseElectricArchivePageQueryDto queryDto) {
        List<CaseElectricArchiveRecordDetailVo> list = caseElectricArchiveRecordService.getElectricArchiveRecordList(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, new PageResponse<>(list));
    }

    /**
     * 查询电子卷宗列表-只查看
     *
     * @return {@link Result<PageResponse<CaseElectricArchiveRecordDetailVo>> }
     */
    @RequestMapping("/getElectricArchiveRecordListToSee")
    public Result<PageResponse<CaseElectricArchiveRecordDetailVo>> getElectricArchiveRecordListToSee(@RequestBody @Validated CaseElectricArchivePageQueryDto queryDto) {
        List<CaseElectricArchiveRecordDetailVo> list = caseElectricArchiveRecordService.getElectricArchiveRecordListToSee(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, new PageResponse<>(list));
    }

    /**
     * 新的证据列表(包含附件和证据列表)
     *
     * @param caseId
     * @return
     */
    @GetMapping("/getElectricArchiveList")
    public Result<List<ElectricInfoVo>> getElectricArchiveList(@RequestParam("caseId") String caseId){
        return Result.success(Constant.STRING_GET_SUCCESS, caseElectricArchiveRecordService.getElectricArchiveList(caseId));
    }

    /**
     * 【V1.9.4】描述：保存电子卷宗
     *
     * @param saveDto 保存dto
     * @return {@link Result<PageResponse<CaseElectricArchiveRecordDetailVo>> }
     * @author shishengyao
     * @date 2022/12/08
     */
    @RequestMapping("/saveElectricArchive")
    public Result<PageResponse<CaseElectricArchiveRecordDetailVo>> saveElectricArchive(@RequestBody @Validated CaseElectricArchiveSaveDto saveDto) {
        int i = caseElectricArchiveRecordService.saveElectricArchive(saveDto);
        if (i > 0) {
            return Result.success(Constant.STRING_SAVE_SUCCESS);
        }
        return Result.error(Constant.STRING_SAVE_FAIL);
    }

    /**
     * 【V1.9.4】描述：保存电子卷宗
     *
     * @param saveDto 保存dto
     * @return {@link Result<PageResponse<CaseElectricArchiveRecordDetailVo>> }
     * @author shishengyao
     * @date 2022/12/08
     */
    @RequestMapping("/calculateElectricArchivePageNumber")
    public Result<List<CaseElectricArchiveCatalogContent>> calculateElectricArchivePageNumber(@RequestBody @Validated CaseElectricArchiveSaveDto saveDto) {
        List<CaseElectricArchiveCatalogContent> list = caseElectricArchiveRecordService.calculateElectricArchivePageNumber(saveDto.getArchiveCatalogContentList());
        if (list.size() > 0) {
            return Result.success(Constant.STRING_SAVE_SUCCESS, list);
        }
        return Result.error(Constant.STRING_SAVE_FAIL);
    }

    /**
     * 【V1.9.4】描述：查询电子卷宗相关文件列表
     *
     * @param queryDto 查询dto
     * @return {@link Result<PageResponse<CaseElectricArchiveRecordDetailVo>> }
     * @author shishengyao
     * @date 2022/12/08
     */
    @RequestMapping("/getCaseElectricArchiveDocumentList")
    public Result<List<CaseElectricArchiveCatalogContent>> getCaseElectricArchiveDocumentList(@RequestBody @Validated CaseElectricArchiveCatalogDocumentQueryDto queryDto) {
        List<CaseElectricArchiveCatalogContent> list = caseElectricArchiveRecordService.getCaseElectricArchiveDocumentList(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, list);
    }

}
